#include <stdio.h>
#include "cu_sftp.h"

int main() {
    const char *username = "xxx";
    const char *password = "xxx";
    const char *ip = "xxx";
    const char *port = "xxx";
    const char *remote_path = "/nas_data/vsftpd/s-lixu/sftp_test.bin";
    const char *remote_path1 = "/nas_data/vsftpd/s-lixu/test.pcap";
    const char *local_path_upload = "/home/self-project/c-utils/network/sftp/sftp_test.bin";
    const char *local_path_download = "/home/self-project/c-utils/network/sftp/test.pcap";
    cu_sftp_t *cu_sftp_handle = cu_sftp_init(ip, port, username, password);
    if (cu_sftp_handle == NULL) {
        fprintf(stderr, "Failed to init cu_sftp_handle.\n");
        return -1;
    }
    bool res = cu_sftp_upload(cu_sftp_handle, remote_path, local_path_upload, true);
    if(!res) {
        fprintf(stderr, "Failed to upload file.\n");
        return -1;
    }
    res = cu_sftp_download(cu_sftp_handle, remote_path1, local_path_download);
    if(!res) {
        fprintf(stderr, "Failed to download file.\n");
        return -1;
    }
    cu_sftp_destroy(cu_sftp_handle);

    return 0;
}